package vip.xiaonuo.smzq.modular.kcl.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import vip.xiaonuo.smzq.modular.kcl.entity.Tkqsqdj;
import vip.xiaonuo.smzq.modular.kcl.mapper.TkqsqdjMapper;
import vip.xiaonuo.smzq.modular.kcl.service.ITkqsqdjService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vip.xiaonuo.common.page.CommonPageRequest;

import javax.annotation.Resource;

/**
 * 探矿权申请登记基本信息 服务实现类
 *
 * @author sqq
 * @since 2024-03-19
 */
@Service
public class TkqsqdjServiceImpl extends ServiceImpl<TkqsqdjMapper, Tkqsqdj> implements ITkqsqdjService {

    @Resource
    private TkqsqdjMapper tkqsqdjMapper;

    @Override
    public Page<Tkqsqdj> page(Tkqsqdj tkqsqdj) {
        QueryWrapper<Tkqsqdj> queryWrapper = new QueryWrapper<>();
        return this.page(CommonPageRequest.defaultPage(), queryWrapper);
    }

    @Override
    public Tkqsqdj getTkqsqdj(Integer djflbm, String kqbm, Integer nd) {
        QueryWrapper<Tkqsqdj> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("djflbh", djflbm).eq("kqbh", kqbm).eq("nd", nd);
        return tkqsqdjMapper.selectOne(queryWrapper);
    }

    @Override
    public int addTkqsqdj(Tkqsqdj tkqsqdj, String kqbh, Integer djflbm, Integer nd) {
        int count=0;
        tkqsqdj.setKqbh(kqbh);
        tkqsqdj.setDjflbh(djflbm);
        tkqsqdj.setNd(nd);
        if (tkqsqdj.getPkid() == null){
            count = tkqsqdjMapper.insert(tkqsqdj);
        }else{
            count = tkqsqdjMapper.updateById(tkqsqdj);
        }






        return count;
    }
}
